local RSNG = RSNG
local AceOO = AceLibrary("AceOO-2.0")
local L = AceLibrary("Ace-Locale-2.2"):new("RSNG")
local C = RSNG.Classes

local Filter = AceOO.Class(C.IFilter, C.ISerializable)

function Filter.prototype:init()
	Filter.super.prototype.init(self)
end

function Filter.prototype:Filter(unit, name, class, group, dead, online)
	if self.include then
		return online
	else
		return not online
	end
end

function Filter.prototype:Serialize(type, data)
	if type == "save" then
		data.include = self.include
	elseif type == "load" then
		self.include = data.include
	end
end

function Filter.prototype:GetOptionTable()
	local t = self.options
	if not t then
		t = {
			type = "toggle",
			name = L["Online"],
			desc = L["Filter online units."],
			get = function () return self.include end,
			set = function (value) self.include = value and true or false end,
		}
		self.options = t
	end
	return t
end

RSNG:RegisterFilter(L["Online Filter"], Filter)
